/*----------------------------------------------------------------------
 *
 * Copyright 2009, Thomas Dejanovic.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 *
 *---------------------------------------------------------------------
 *
 * Tasks to access registers via the dcom apb interface.
 *
 *---------------------------------------------------------------------*/

`include "dcom_uart_tasks.vh"

`ifndef DCOM_APB_TASKS

 `define DCOM_APB_TASKS

parameter READ_OPCODE  = 8'h21;
parameter WRITE_OPCODE = 8'h22;

task uart_read;
  input [29:0]  a;
  output [31:0] b;
  begin
    uart_send_byte(READ_OPCODE);
    uart_send_byte(a[29:22]);
    uart_send_byte(a[21:14]);
    uart_send_byte(a[13: 6]);
    uart_send_byte({a[ 5: 0], 2'd0});
    uart_get_byte(b[31:24]);
    uart_get_byte(b[23:16]);
    uart_get_byte(b[15: 8]);
    uart_get_byte(b[ 7: 0]);
    $display("// uart_read 0x%6x from location 0x%6x",b,a);
  end
endtask // uart_read


task uart_write;
  input [29:0] a;
  input [31:0] b;
  reg [7:0]   uwob_rx_data;
  begin
    uart_send_byte(WRITE_OPCODE);
    uart_send_byte(a[29:22]);
    uart_send_byte(a[21:14]);
    uart_send_byte(a[13: 6]);
    uart_send_byte({a[ 5: 0], 2'd0});
    uart_send_byte(b[31:24]);
    uart_send_byte(b[23:16]);
    uart_send_byte(b[15: 8]);
    uart_send_byte(b[ 7: 0]);
    $display("// uart_write 0x%6x to location 0x%6x",b,a);
  end
endtask // uart_write

`endif //  `ifndef DCOM_APB_TASKS

/*----------------------------------------------------------------*/

// Local Variables:
// mode: verilog
// End:
